package com.sanery.service.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.sanery.dao.MyBatisUtil;
import com.sanery.dao.SiteDao;
import com.sanery.entity.MySite;
import com.sanery.service.SiteService;

public class SiteServiceImpl implements SiteService {

	SqlSession session = MyBatisUtil.getSession();
	private SiteDao dao = session.getMapper(SiteDao.class);

	@Override
	public List<MySite> getAllSite(Integer userid) {
		List<MySite> list = dao.getAllSite(userid);
		session.commit();// 提交事务
		MyBatisUtil.closeSession();
		return list;
	}

	@Override
	public void addSite(String s_title, String s_cgy, String s_link, Integer u_id) {
		dao.addSite(s_title, s_link, s_cgy, u_id);
		session.commit();// 提交事务
		MyBatisUtil.closeSession();
	}

	@Override
	public void delSite(Integer s_id) {
		dao.delSite(s_id);
		session.commit();// 提交事务
		MyBatisUtil.closeSession();
	}

	@Override
	public void changeSite(String s_title, String s_cgy, String s_link, Integer s_id) {
		dao.changeSite(s_title, s_link, s_cgy, s_id);
		session.commit();// 提交事务
		MyBatisUtil.closeSession();

	}

	@Override
	public MySite getOneSite(Integer s_id) {
		MySite site = (MySite) dao.getOneSite(s_id);
		session.commit();// 提交事务
		MyBatisUtil.closeSession();
		return site;
	}

}
